import request from '@/utils/request'

/**
 * 用户登录
 * @param data
 * @returns
 */
export const login = (data: object) => {
  return request.post('/authorize', data)
}


/**
 * 动态路由
 * @returns
 */
export const getRoutesApi = () => {
  return request.get('/auth/admin/mySelf')
}


/**
 * 菜单列表
 * @param params
 * @returns
 */
export const getMenuListApi = (params:any) => {
  return request.get('/auth/menu/lists', { params: params })
}

/**
 * 添加菜单
 * @param params
 * @returns
 */
export const addMenuApi = (params: any) => {
  return request.post('/auth/menu/create', params)
}

/**
 * 修改菜单
 * @param params
 * @returns
 */
export const updateMenuApi = (params: any) => {
  return request.put(`/auth/menu/update`, params)
}

/**
 * 删除菜单
 * @param id
 * @returns
 */
export const deleteMenuApi = (id: number) => {
  return request.delete(`/auth/menu/delete`,{params:{id:id}})
}

/**
 * 获取父级菜单列表
 * @param params
 * @returns
 */
export const getParentMenuListApi = (params:any) => {
  return request.get('/auth/menu/parentLists',{params:params})
}


/**
 * 角色列表
 * @param params
 * @returns
 */
export const getRoleListApi = (params:any) => {
  return request.get('/auth/role/lists', { params: params })
}

/**
 * 新增角色
 * @param params
 * @returns
 */
export const addRoleApi = (params: any) => {
  return request.post('/auth/role/create', params)
}

/**
 * 修改角色
 * @param params
 * @returns
 */
export const updateRoleApi = (params: any) => {
  return request.put(`/auth/role/update`, params)
}

/**
 * 删除角色
 * @param id
 * @returns
 */
export const deleteRoleApi = (id: number) => {
  return request.delete(`/auth/role/delete`,{params:{id:id}})
}


/**
 * 管理员列表
 * @param params
 * @returns
 */
export const getAdminListApi = (params:any) => {
  return request.get('/auth/admin/lists', { params: params })
}

/**
 * 新增管理员
 * @param params
 * @returns
 */
export const addAdminApi = (params: any) => {
  return request.post('/auth/admin/create', params)
}

/**
 * 修改管理员
 * @param params
 * @returns
 */
export const updateAdminApi = (params: any) => {
  return request.put(`/auth/admin/update`, params)
}

/**
 * 删除管理员
 * @param id
 * @returns
 */
export const deleteAdminApi = (id: number) => {
  return request.delete(`/auth/admin/delete`,{params:{id:id}})
}

/**
 * 修改当前管理员信息
 * @param params
 * @returns
 */
export const editCurrentAdminApi = (params: any) => {
  return request.put(`/auth/admin/editCurrentAdmin`, params)
}
